package server;


import java.io.IOException;

public class ZjServlet extends MyHttpServlet {


    @Override
    public void doGet(Request request, Response response) {
        String content = "<h1> welcome to demo1 servlet get  </h1>";
        //设置响应头
        String httpHeader200 = HttpProtocolUtil.getHttpHeader200(content.getBytes().length);
        try {
            response.outPutMessage(httpHeader200+content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        String content = "<h1> welcome to demo1 servlet post  </h1>";
        //设置响应头
        String httpHeader200 = HttpProtocolUtil.getHttpHeader200(content.getBytes().length);
        try {
            response.outPutMessage(httpHeader200+content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void init() throws Exception {
        System.out.println("demo1 ZjServlet init");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("demo1 ZjServlet destroy");
    }
}
